#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;

#include <stdio.h>
#include <string.h>

class Solution {
public:
    vector<string> uncommonFromSentences(string s1, string s2) {
        vector<string> ret;
        unordered_map<string, int> hash;
        int i = 0, j = 0;

        for (; j < s1.size(); )
        {
            if (s1[j] == ' ')
            {
                string s(s1.begin() + i, s1.begin() + j);
                hash[s]++;

                j++;
                i = j;
            }
            else j++;
        }
        hash[string(s1.begin() + i, s1.begin() + j)]++;

        for (i = 0, j = 0; j < s2.size(); )
        {
            if (s2[j] == ' ')
            {
                string s(s2.begin() + i, s2.begin() + j);
                hash[s]++;

                j++;
                i = j;
            }
            else j++;
        }
        hash[string(s2.begin() + i, s2.begin() + j)]++;

        for (auto& e : hash)
        {
            if (e.second == 1)
                ret.push_back(e.first);
        }

        return ret;
    }
};

int main()
{
    FILE* fp = fopen("bite.txt", "w+");
    if (fp == NULL)
    {
        perror("open file fail");
        return 1;
    }

    const char* s = "linux so easy";

    fprintf(fp, s);
    fclose(fp);
    fp = NULL;

    fp = fopen("bite.txt", "r");
    if (fp == NULL)
    {
        perror("open file fail");
        return 1;
    }

    char s1[20] = { 0 };
    int len = strlen(s);
    fgets(s1, len + 1, fp);
    printf("%s\n", s1);

	return 0;
}